export default {
  bind (el, binding, vnode) {
    function handler (e) {
      if (el.contains(e.target)) {
        return false
      }

      if (binding.expression) {
        binding.value(e)
      }
    }
    el._vueClickOutside = handler
    document.addEventListener('click', handler)
  },

  update () {},

  unbind (el, binding) {
    document.removeEventListener('click', el._vueClickOutside)
    delete el._vueClickOutside
  }
}
